<?php
class Pageley_Tag_Message extends Pageley_Tag_Abstract implements Pageley_Tag_Parametrizable {
    
    private $messageKey;
    private $parameters;
    
    public function __construct() {
    	$this->parameters = new Pageley_Util_ArrayMap();
    }
    
    public function execute() {
        $config = Pageley_Config::getInstance();
    	$dictionary = $config->valueOf("dictionary");
    	$locales = $_SESSION["pageley.locales"];
    	$locale = null;
    	if($locales !== null && $locales->size() > 0) {
    	   $locale = $locales->get(0);
    	}
    	return $dictionary->translate($locale, $this->messageKey, $this->parameters);
    }
    
    public function setMessageKey($messageKey) {
        $this->messageKey = $messageKey;
    }
    
    public function setParameter($name, $value) {
    	$this->parameters->put($name, $value);
    }
}